<template>
  <el-dialog title="配镜详情信息" :close-on-click-modal="false" :visible.sync="visible" fullscreen append-to-body>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <el-tabs type="border-card"  v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="配镜单详情" name='配镜单详情'>
        <el-row>
          <a :href="printUrl" target="_blank"><el-button size="mini" type="text" icon="el-icon-printer" style="margin-right: 10px;" @click="saleGlassPrint(dataForm.id)">打印配镜单</el-button></a>
          <a :href="printUrl" target="_blank"><el-button size="mini" type="text" icon="el-icon-printer" style="margin-right: 10px;" @click="saleRefundGlassPrint(dataForm.id)">打印部分退款配镜单</el-button></a>
        </el-row>
        <el-form :model="dataForm" ref="dataForm" label-width="120px" size="mini">
            <div class="text item">
              <el-divider content-position="center">查询条件</el-divider>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="配镜单号" prop="billId">
                    <el-input v-model="dataForm.billId" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="配镜部门" prop="mirroDeptName" >
                    <el-input v-model="dataForm.mirroDeptName" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="销售单类型" prop="saleType" >
                    <el-input :value="valueOrNameTypeChange(dataForm.saleType)" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="取镜部门" prop="takeMirroDeptName" >
                    <el-input v-model="dataForm.takeMirroDeptName" readonly></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="预计取镜时间" prop="takeMirroTime" >
                    <el-input v-model="dataForm.takeMirroTime" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="实际取镜时间" prop="actulTakeMirroTime" >
                    <el-input v-model="dataForm.actulTakeMirroTime" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="加工部门" prop="workDeptName">
                    <el-input  v-model="dataForm.workDeptName" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item  label="邮寄状态(未查)" prop="aa">
                    <el-input v-model="dataForm.aa" readonly></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="顾客姓名" prop="name">
                    <el-input v-model="dataForm.name" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="联系电话" prop="phone1">
                    <el-input v-model="dataForm.phone1" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="顾客年龄" prop="saleTodayAge">
                    <el-input  v-model="dataForm.saleTodayAge" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="关联顾客卡" prop="customerCard">
                    <el-input  v-model="dataForm.customerCard" readonly></el-input>
                  </el-form-item>
                </el-col>

              </el-row>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="付款状态" prop="payStatus">
                    <el-input  :value="payStatusTypeChange(dataForm.payStatus)" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="收银日期" prop="payTime">
                    <el-input  v-model="dataForm.payTime" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="实际收银日期" prop="payTime">
                    <el-input  v-model="dataForm.payTime" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="收银员" prop="payeeUsername">
                    <el-input  v-model="dataForm.payeeUsername" readonly></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="原价总金额" prop="originalPrice">
                    <el-input  v-model="dataForm.originalPrice" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="折扣金额" prop="discountPrice">
                    <el-input  v-model="dataForm.discountPrice" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="抹零金额" prop="removeprice">
                    <el-input  v-model="dataForm.removeprice" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="应收金额" prop="receivablePrice">
                    <el-input  v-model="dataForm.receivablePrice" readonly></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="实收金额" prop="paidPrice">
                    <el-input  v-model="dataForm.paidPrice" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="打折人" prop="discountUsername">
                    <el-input  v-model="dataForm.discountUsername" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="套餐id" prop="setmealId">
                    <el-input  v-model="dataForm.setmealId" readonly></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="退款状态" prop="refundFlag">
                    <el-input  :value="refundFlagChange(dataForm.refundFlag)" readonly ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="退款时间" prop="refundTime">
                    <el-input  v-model="dataForm.refundTime" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="实际退款时间" prop="refundTime">
                    <el-input  v-model="dataForm.refundTime" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="累计门店积分" prop="integral">
                    <el-input  v-model="dataForm.storesIntegral" readonly></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="累计医院积分" prop="integral">
                    <el-input  v-model="dataForm.integral" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="获取商品总积分" prop="totalIntegral">
                    <el-input  v-model="dataForm.totalIntegral" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="结款修改后积分" prop="ddd">
                    <el-input  v-model="dataForm.ddd" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="积分抵扣金额">
                    <el-input  v-model="dataForm.deductionPrice" readonly></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="处方备注">
                    <el-input  v-model="dataForm.saleOptometry.memo" readonly type="textarea"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="24">
                  <el-form-item label="销售备注">
                    <el-input  v-model="dataForm.memo" readonly type="textarea"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-divider content-position="center" v-if="optometryDetail.optType">视光详情</el-divider>
              <table class="miui-table" v-if="optometryDetail.optType">
                <tr>
                  <th>右眼(OD)/左眼(OS)</th>
                  <th v-if="['8','9'].includes(optometryDetail.optType)">试戴片编号</th>
                  <th v-if="optometryDetail.optType == '8'">FK</th>
                  <th v-if="optometryDetail.optType == '8'">曲率半径</th>
                  <th v-if="optometryDetail.optType == '8'">AC</th>
                  <th v-if="optometryDetail.optType == '10'">屈光度</th>
                  <th v-if="['3','8','9','10'].includes(optometryDetail.optType)">BC</th>
                  <th v-if="['1','2','3','4','5','6','7'].includes(optometryDetail.optType)">球镜</th>
                  <th v-if="['1','2','3','4','5','6','7'].includes(optometryDetail.optType)">柱镜</th>
                  <th v-if="['1','2','3','4','5','6','7'].includes(optometryDetail.optType)">轴向</th>
                  <th v-if="optometryDetail.optType == '4'">ADD</th>
                  <th v-if="['1','2','4','5','7'].includes(optometryDetail.optType)">三棱镜</th>
                  <th v-if="['1','2','4','5','7'].includes(optometryDetail.optType)">基底</th>
                  <th v-if="['1','2','4','5'].includes(optometryDetail.optType)">瞳高(mm)</th>
                  <th v-if="['1','4','5','7'].includes(optometryDetail.optType)">远用瞳距(mm)</th>
                  <th v-if="['2','4','7'].includes(optometryDetail.optType)">近用瞳距(mm)</th>
                  <th v-if="['1','4','7'].includes(optometryDetail.optType)">远用VA</th>
                  <th v-if="['2','4','7'].includes(optometryDetail.optType)">近用VA</th>
                  <th v-if="optometryDetail.optType== '5'">中用VA</th>
                  <th v-if="optometryDetail.optType== '6'">平K</th>
                  <th v-if="optometryDetail.optType== '6'">陡K</th>
                  <th v-if="optometryDetail.optType== '6'">e值</th>
                  <th v-if="optometryDetail.optType== '6'">角膜直径</th>
                  <th v-if="optometryDetail.optType== '6'">试戴片K</th>
                  <th v-if="optometryDetail.optType== '6'">K1</th>
                  <th v-if="optometryDetail.optType== '6'">k2</th>
                  <th v-if="optometryDetail.optType== '6'">光度</th>
                  <th v-if="optometryDetail.optType== '3'">曲率1</th>
                  <th v-if="optometryDetail.optType== '3'">曲率2</th>
                  <th v-if="['3','6'].includes(optometryDetail.optType)">直径</th>
                  <!--<th v-if="optometryDetail.optType== '3'">隐形VA</th>-->
                  <th v-if="['3','6'].includes(optometryDetail.optType)">片/盒数</th>
                  <th v-if="optometryDetail.optType == '9'">RZD</th>
                  <th v-if="optometryDetail.optType == '9'">LZA</th>
                  <th v-if="optometryDetail.optType == '9'">RZD2</th>
                  <th v-if="['8','9'].includes(optometryDetail.optType)">降幅</th>
                  <th v-if="['8','9','10'].includes(optometryDetail.optType)">DIA</th>
                  <th v-if="optometryDetail.optType == '8'">E值</th>
                  <th v-if="['8','9'].includes(optometryDetail.optType)">VA</th>
                  <th v-if="optometryDetail.optType == '10'">散光</th>
                  <th>镜片种类</th>
                </tr>
                <tr>
                  <td>OD</td>
                  <td v-if="['8','9'].includes(optometryDetail.optType)">{{optometryDetail.tryNumberOd}}</td>
                  <td v-if="optometryDetail.optType == '8'">{{optometryDetail.fkOd}}</td>
                  <td v-if="optometryDetail.optType == '8'">{{optometryDetail.curvatureRadiusOd}}</td>
                  <td v-if="optometryDetail.optType == '8'">{{optometryDetail.acOd}}</td>
                  <td v-if="optometryDetail.optType == '10'">{{optometryDetail.diopterOd}}</td>
                  <td v-if="['3','8','9','10'].includes(optometryDetail.optType)">{{optometryDetail.bcOd}}</td>
                  <td v-if="['1','2','3','4','5','6','7'].includes(optometryDetail.optType)">{{optometryDetail.ballGlassOd}}</td>
                  <td v-if="['1','2','3','4','5','6','7'].includes(optometryDetail.optType)">{{optometryDetail.postGlassOd}}</td>
                  <td v-if="['1','2','3','4','5','6','7'].includes(optometryDetail.optType)">{{optometryDetail.axesOd}}</td>
                  <td v-if="optometryDetail.optType == '4'">{{optometryDetail.addOd}}</td>
                  <td v-if="['1','2','4','5','7'].includes(optometryDetail.optType)">{{optometryDetail.arriseGlassOd}}</td>
                  <td v-if="['1','2','4','5','7'].includes(optometryDetail.optType)">{{basalTypeChange(optometryDetail.basisOd)}}</td>
                  <td v-if="['1','2','4','5'].includes(optometryDetail.optType)">{{optometryDetail.pupilHighOd}}</td>
                  <td v-if="['1','4','5','7'].includes(optometryDetail.optType)">{{optometryDetail.farPupilDistanceOd}}</td>
                  <td v-if="['2','4','7'].includes(optometryDetail.optType)">{{optometryDetail.nearPupilDistanceOd}}</td>
                  <td v-if="['1','4','7'].includes(optometryDetail.optType)">{{optometryDetail.farUseOd}}</td>
                  <td v-if="['2','4','7'].includes(optometryDetail.optType)">{{optometryDetail.nearUseOd}}</td>
                  <td v-if="optometryDetail.optType== '5'">{{optometryDetail.farUseOd}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.smoothKOd}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.steepKOd}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.valueEOd}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.cornealDiameterOd}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.tryKOd}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.k1Od}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.k2Od}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.luminosityOd}}</td>
                  <td v-if="optometryDetail.optType== '3'">{{optometryDetail.curvatureOd1}}</td>
                  <td v-if="optometryDetail.optType== '3'">{{optometryDetail.curvatureOd2}}</td>
                  <td v-if="['3','6'].includes(optometryDetail.optType)">{{optometryDetail.diameterOd}}</td>
                 <!-- <td v-if="optometryDetail.optType== '3'">{{optometryData.invisibleOd}}</td>-->
                  <td v-if="['3','6'].includes(optometryDetail.optType)">{{optometryDetail.numberBoxOd}}</td>
                  <td v-if="optometryDetail.optType == '9'">{{optometryDetail.rzdOd}}</td>
                  <td v-if="optometryDetail.optType == '9'">{{optometryDetail.lzaOd}}</td>
                  <td v-if="optometryDetail.optType == '9'">{{optometryDetail.rzdOd2}}</td>
                  <td v-if="['8','9'].includes(optometryDetail.optType)">{{optometryDetail.declineOd}}</td>
                  <td v-if="['8','9','10'].includes(optometryDetail.optType)">{{optometryDetail.diaOd}}</td>
                  <td v-if="optometryDetail.optType == '8'">{{optometryDetail.valueEOd}}</td>
                  <td v-if="['8','9'].includes(optometryDetail.optType)">{{optometryDetail.vaOd}}</td>
                  <td v-if="optometryDetail.optType == '10'">{{optometryDetail.astigmiaOd}}</td>
                  <td>{{valueOrNameTypeChange(dataForm.saleType)}}</td>
                </tr>
                <tr>
                  <td>OS</td>
                  <td v-if="['8','9'].includes(optometryDetail.optType)">{{optometryDetail.tryNumberOs}}</td>
                  <td v-if="optometryDetail.optType == '8'">{{optometryDetail.fkOs}}</td>
                  <td v-if="optometryDetail.optType == '8'">{{optometryDetail.curvatureRadiusOs}}</td>
                  <td v-if="optometryDetail.optType == '8'">{{optometryDetail.acOs}}</td>
                  <td v-if="optometryDetail.optType == '10'">{{optometryDetail.diopterOs}}</td>
                  <td v-if="['3','8','9','10'].includes(optometryDetail.optType)">{{optometryDetail.bcOs}}</td>
                  <td v-if="['1','2','3','4','5','6','7'].includes(optometryDetail.optType)">{{optometryDetail.ballGlassOs}}</td>
                  <td v-if="['1','2','3','4','5','6','7'].includes(optometryDetail.optType)">{{optometryDetail.postGlassOs}}</td>
                  <td v-if="['1','2','3','4','5','6','7'].includes(optometryDetail.optType)">{{optometryDetail.axesOs}}</td>
                  <td v-if="optometryDetail.optType == '4'">{{optometryDetail.addOs}}</td>
                  <td v-if="['1','2','4','5','7'].includes(optometryDetail.optType)">{{optometryDetail.arriseGlassOs}}</td>
                  <td v-if="['1','2','4','5','7'].includes(optometryDetail.optType)">{{basalTypeChange(optometryDetail.basisOs)}}</td>
                  <td v-if="['1','2','4','5'].includes(optometryDetail.optType)">{{optometryDetail.pupilHighOs}}</td>
                  <td v-if="['1','4','5','7'].includes(optometryDetail.optType)">{{optometryDetail.farPupilDistanceOs}}</td>
                  <td v-if="['2','4','7'].includes(optometryDetail.optType)">{{optometryDetail.nearPupilDistanceOs}}</td>
                  <td v-if="['1','4','7'].includes(optometryDetail.optType)">{{optometryDetail.farUseOs}}</td>
                  <td v-if="['2','4','7'].includes(optometryDetail.optType)">{{optometryDetail.nearUseOs}}</td>
                  <td v-if="optometryDetail.optType== '5'">{{optometryDetail.farUseOs}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.smoothKOs}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.steepKOs}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.valueEOs}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.cornealDiameterOs}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.tryKOs}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.k1Os}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.k2Os}}</td>
                  <td v-if="optometryDetail.optType== '6'">{{optometryDetail.luminosityOs}}</td>
                  <td v-if="optometryDetail.optType== '3'">{{optometryDetail.curvatureOs1}}</td>
                  <td v-if="optometryDetail.optType== '3'">{{optometryDetail.curvatureOs2}}</td>
                  <td v-if="['3','6'].includes(optometryDetail.optType)">{{optometryDetail.diameterOs}}</td>
                 <!-- <td v-if="optometryDetail.optType== '3'">{{optometryData.invisibleOs}}</td>-->
                  <td v-if="['3','6'].includes(optometryDetail.optType)">{{optometryDetail.numberBoxOs}}</td>
                  <td v-if="optometryDetail.optType == '9'">{{optometryDetail.rzdOs}}</td>
                  <td v-if="optometryDetail.optType == '9'">{{optometryDetail.lzaOs}}</td>
                  <td v-if="optometryDetail.optType == '9'">{{optometryDetail.rzdOs2}}</td>
                  <td v-if="['8','9'].includes(optometryDetail.optType)">{{optometryDetail.declineOs}}</td>
                  <td v-if="['8','9','10'].includes(optometryDetail.optType)">{{optometryDetail.diaOs}}</td>
                  <td v-if="optometryDetail.optType == '8'">{{optometryDetail.valueEOs}}</td>
                  <td v-if="['8','9'].includes(optometryDetail.optType)">{{optometryDetail.vaOs}}</td>
                  <td v-if="optometryDetail.optType == '10'">{{optometryDetail.astigmiaOs}}</td>
                  <td>{{valueOrNameTypeChange(dataForm.saleType)}}</td>
                </tr>
              </table>
              <el-row></el-row>
              <table class="miui-table" v-if="optometryDetail.optType">
                <tr>
                  <th>旧瞳距</th>
                  <th>片高</th>
                  <th>片宽</th>
                  <th>中梁</th>
                  <th>镜片通道</th>
                  <th>对角线</th>
                  <th>框型</th>
                </tr>
                <tr>
                  <td>{{optometryDetail.oldPupilDistance}}</td>
                  <td>{{optometryDetail.chipHeight}}</td>
                  <td>{{optometryDetail.chipWidth}}</td>
                  <td>{{optometryDetail.centreSill}}</td>
                  <td>{{optometryDetail.glassesChannel}}</td>
                  <td>{{optometryDetail.diagonal}}</td>
                  <td>{{optometryDetail.frameModel}}</td>
                </tr>
              </table>
              <el-divider content-position="center">配镜单商品列表详情</el-divider>
              <el-table :data="saleDetailDTOList" border v-loading="dataListLoading">
                <el-table-column prop="code" label="商品代码" width="150"></el-table-column>
                <el-table-column prop="goodsDisplayName" label="商品名称"></el-table-column>
                <el-table-column prop="price" label="单价" width="80"></el-table-column>
                <el-table-column prop="goodsQuantity" label="数量" width="50"></el-table-column>
                <el-table-column prop="originalPrice" label="原价合计" width="90"></el-table-column>
                <el-table-column prop="discountRate" label="折扣率" width="60"></el-table-column>
                <el-table-column prop="discountPrice" label="折扣金额" width="70"></el-table-column>
                <el-table-column prop="removePrice" label="抹零金额" width="70"></el-table-column>
                <el-table-column prop="receivablePrice" label="应收金额" width="120"></el-table-column>
                <el-table-column prop="goodsDescription" label="商品描述" width="80"></el-table-column>
              </el-table>

              <div v-if="refundDetailList.length">
                <el-divider content-position="center">退货商品列表</el-divider>
                <el-table :data="refundDetailList" ref="goodsTable" border style="color: red;">
                  <el-table-column prop="goodsCode" label="商品代码" width="150"></el-table-column>
                  <el-table-column prop="goodsDisplayName" label="商品名称"></el-table-column>
                  <el-table-column prop="price" label="单价" width="80"></el-table-column>
                  <el-table-column prop="refundNumber" label="退货数量" width="80"></el-table-column>
                  <el-table-column prop="refundPrice" label="退款金额" width="120"></el-table-column>
                  <el-table-column prop="goodsDescription" label="商品描述" width="80"></el-table-column>
                </el-table>
              </div>

            </div>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="在途记录" name="在途记录">
        <in-transit-index v-if="twoVisible" ref="twoTab" :billId="dataForm.billId"></in-transit-index>
      </el-tab-pane>
      <el-tab-pane label="库存详细" name="库存详细">
        <inventory-index v-if="threeVisible" ref="threeTab" :billId="dataForm.billId"></inventory-index>
      </el-tab-pane>
      <el-tab-pane label="付款记录" name="付款记录">
        <pay-index v-if="fourVisible" ref="fourTab" :billId="dataForm.billId"></pay-index>
      </el-tab-pane>
      <el-tab-pane label="检验信息" name="检验信息" v-if="dataForm.saleType ==2 ||dataForm.saleType ==4">
        <work-check v-if="fiveVisible" ref="fiveTab" :id="dataForm.id"></work-check>
      </el-tab-pane>
    </el-tabs>

  </el-dialog>
</template>

<script>
  import {mapGetters} from 'vuex'
  import { getObj, getObjByBillId } from '@/api/eims/optician/glassesinfo'
  import { getSaleRefundDetailListBySaleId, getSaleRefundDetailListByBillId } from '@/api/eims/salerefunddetail'
  import InventoryIndex from './inventoryIndex'
  import PayIndex from './payIndex'
  import InTransitIndex from './inTransitIndex'
  import WorkCheck from './workCheck'

  export default {
    data() {
      return {
        activeName: '配镜单详情',
        visible: false,
        printUrl: '',
        deptData: {},
        dataForm: {
          saleOptometry: {},
          memo: ''
        },
        saleDetailDTOList: [],
        refundDetailList: [],
        optometryDetail: {
          memo: '',
          ballGlassOd: ''
        },
        typeOptions: [
          {value: '1', name: '隐形订做'},
          {value: '2', name: '框镜订做'},
          {value: '3', name: '隐形成品'},
          {value: '4', name: '框镜成品'},
          {value: '5', name: '辅料'}
        ],
        payStatusOptions: [
          {value: '1', name: '未付款'},
          {value: '2', name: '已付款'},
          {value: '3', name: '支付失败'}
        ],
        refundFlagOptions: [
          {value: '1', name: '已退款'},
          {value: '0', name: '未退款'}
        ],
        basalTypeData: [
          {value: '1',label: '内'},
          {value: '2',label: '外'},
          {value: '3',label: '上'},
          {value: '4',label: '下'},
        ],
        dataListLoading: false,
        twoVisible: false,
        threeVisible: false,
        fourVisible: false,
        fiveVisible: false
      }
    },
    components: {
      InventoryIndex,
      PayIndex,
      InTransitIndex,
      WorkCheck
    },
    computed: {
      ...mapGetters(['bizData'])
    },
    methods: {
      init(id,billId,name) {
        this.visible = true;
        this.activeName = name;
        let param = {}
        this.refundDetailList = []
        param.name = name
        this.dataListLoading = true;
        this.$nextTick(() => {
          // this.$refs['dataForm'].resetFields()
          if(id){
            getObj(id).then(response => {
              if(response.data.code == '0'){
                let resultData = response.data.data
                if(!resultData.saleOptometry){
                  resultData.saleOptometry = {}
                  resultData.saleOptometry.memo = ''
                }
                this.dataForm = resultData
                this.saleDetailDTOList = this.dataForm.saleDetailDTOList || {}
                if(this.dataForm.saleOptometry){
                	if(parseFloat(this.dataForm.saleOptometry.ballGlassOd) > 0){
                	  this.dataForm.saleOptometry.ballGlassOd = '+' + this.dataForm.saleOptometry.ballGlassOd
                	}
                	if(parseFloat(this.dataForm.saleOptometry.ballGlassOs) > 0){
                	  this.dataForm.saleOptometry.ballGlassOs = '+' + this.dataForm.saleOptometry.ballGlassOs
                	}
                }
                this.optometryDetail = this.dataForm.saleOptometry || {}
                this.getSaleRefundDetailListInSaleId(id)
              }else{
                this.$message.error(response.data.msg)
              }
            }).then(() => {
              this.handleClick(param)
            })
          }else{
            getObjByBillId(billId).then(response => {
              if(response.data.code == '0'){
                let resultData = response.data.data
                if(!resultData.saleOptometry){
                  resultData.saleOptometry = {}
                  resultData.saleOptometry.memo = ''
                }
                this.dataForm = resultData
                this.dataForm = resultData
                this.$set(this.dataForm,'memo',this.dataForm.memo || '')
                this.saleDetailDTOList = this.dataForm.saleDetailDTOList || {}
                if(this.dataForm.saleOptometry){
                	if(parseFloat(this.dataForm.saleOptometry.ballGlassOd) > 0){
                	  this.dataForm.saleOptometry.ballGlassOd = '+' + this.dataForm.saleOptometry.ballGlassOd
                	}
                	if(parseFloat(this.dataForm.saleOptometry.ballGlassOs) > 0){
                	  this.dataForm.saleOptometry.ballGlassOs = '+' + this.dataForm.saleOptometry.ballGlassOs
                	}
                }
                this.optometryDetail = this.dataForm.saleOptometry || {}
                this.dataForm = {...this.dataForm}
                this.getSaleRefundDetailListInBillId(billId)
              }else{
                this.$message.error(response.data.msg)
              }
            }).then(() => {
              this.handleClick(param)
            })
          }

        })
        this.dataListLoading = false;
      },
      //根据销售单ID获取退货详情
      getSaleRefundDetailListInSaleId(paramsId){
        getSaleRefundDetailListBySaleId(paramsId).then(response => {
          if(response.data.code == '0'){
            this.refundDetailList = response.data.data
            this.refundDetailList.forEach((item,index) => {
              this.refundDetailList[index].refundPrice = item.price * item.refundNumber
            })
            this.refundDetailList = [...this.refundDetailList]
          }else{
            this.$message.error(response.data.msg)
          }
        })
      },
      //根据销售单单号获取退货详情
      getSaleRefundDetailListInBillId(paramsId){
        getSaleRefundDetailListByBillId(paramsId).then(response => {
          if(response.data.code == '0'){
            this.refundDetailList = response.data.data
            this.refundDetailList.forEach((item,index) => {
              this.refundDetailList[index].refundPrice = item.price * item.refundNumber
            })
            this.refundDetailList = [...this.refundDetailList]
          }else{
            this.$message.error(response.data.msg)
          }
        })
      },
      handleClick(tab, event) {
        if(tab.name =="配镜单详情"){

        }else if(tab.name =="在途记录"){
          this.twoVisible = true
          this.$nextTick(() => {
            this.$refs.twoTab.init(this.dataForm.billId)
          })
        }else if(tab.name =="库存详细"){
          this.threeVisible = true
          this.$nextTick(() => {
            this.$refs.threeTab.init(this.dataForm.billId)
          })
        }else if(tab.name =="付款记录"){
          this.fourVisible = true
          this.$nextTick(() => {
            this.$refs.fourTab.init(this.dataForm.billId)
          })
        }else if(tab.name =="检验信息"){
          this.fiveVisible = true
          this.$nextTick(() => {
            this.$refs.fiveTab.init(this.dataForm.id)
          })
        }
      },
      // 基底转换
      basalTypeChange(value){
        let obj = {}
        obj = this.basalTypeData.find(item => {
          if(item.value == value){
            return item
          }
        })
        if(obj && obj.label){
          return obj.label
        }
      },
      //  类型转换
      valueOrNameTypeChange(value) {
        let obj = {}
        obj = this.typeOptions.find(item => {
          if(item.value == value){
            return item
          }
        })
        if(obj && obj.name){
          return obj.name
        }
      },
      //支付状态类型转换
      payStatusTypeChange(value) {
        let obj = {}
        obj = this.payStatusOptions.find(item => {
          if(item.value == value){
            return item
          }
        })
        if(obj && obj.name){
          return obj.name
        }
      },
      refundFlagChange(value) {
        let obj = {}
        obj = this.refundFlagOptions.find(item => {
          if(item.value == value){
            return item
          }
        })
        if(obj && obj.name){
          return obj.name
        }
      },
      //  打印配镜单
      saleGlassPrint(id) {
        let params = '/saleGlassPrint_ykyy.cpt&wFlag=1&saleId='
        this.printUrl = this.bizData.printUrl + params + id
      },
      saleRefundGlassPrint(id){
        let params = '/saleGlassPrint_ykyy_refund.cpt&wFlag=1&saleId='
        this.printUrl = this.bizData.printUrl + params + id
      }
    }

  }
</script>
<style lang="scss" scoped>
.miui-table {
  width: 100%;
}
  .miui-table tr>th,.miui-table tr>td {
    border: solid 1px #fff;
    height: 33px;
		background-color: #b1e2ec3b;
    padding: 3px 5px;
    text-align: center;
  }
</style>
